/*
         bind:绑定时，类似beforeMount
         inserted:渲染后，类似mounted
         update:更新时，
         componentUpdated:更新后，类似updated
         unbind:解绑，销毁后，类似destroyed
      */
// obj:{属性，修饰符，值value}

const obj = {
  role: {
    inserted(dom, obj) {
      switch (obj.value) {
        case 1:
          dom.innerText = "管理员";
          break;
        case 2:
          dom.innerText = "老师";
          break;
        case 3:
          dom.innerText = "学生";
          break;
      }
    },
    componentUpdated(dom, obj) {
      //   console.log("obj", obj);
      switch (obj.value) {
        case 1:
          dom.innerText = "管理员";
          break;
        case 2:
          dom.innerText = "老师";
          break;
        case 3:
          dom.innerText = "学生";
          break;
      }
    },
  },
  status: {
    inserted(dom, obj) {
      switch (obj.value) {
        case 1:
          dom.innerText = "启用";
          break;
        case 2:
          dom.innerText = "禁用";
          break;
      }
    },
    componentUpdated(dom, obj) {
      switch (obj.value) {
        case 1:
          dom.innerText = "启用";
          break;
        case 0:
          dom.innerText = "禁用";
          break;
      }
    },
  },
  statusTwo: {
    inserted(dom, obj) {
      //   console.log("inserted obj", obj);
      switch (obj.value) {
        case 1:
          dom.innerText = "禁用";
          break;
        case 0:
          dom.innerText = "启用";
          break;
      }
    },
    componentUpdated(dom, obj) {
      //   console.log("componentUpdated", obj);

      switch (obj.value) {
        case 1:
          dom.innerText = "禁用";
          break;
        case 0:
          dom.innerText = "启用";
          break;
      }
    },
  },
};

export default {
  install(Vue) {
    for (const key in obj) {
      Vue.directive(key, obj[key]);
    }
  },
};
